{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from math import ceil\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "import h5py\n",
    "\n",
    "import dask.array as da\n",
    "import dask.dataframe as dd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "h5_3L = h5py.File('ag1000g.phase1.ar3.pass.3L.h5', 'r')\n",
    "positions = h5_3L['/3L/variants/POS']\n",
    "is_snp = h5_3L['/3L/variants/is_snp']\n",
    "qual = h5_3L['/3L/variants/QUAL']\n",
    "mq0 = h5_3L['/3L/variants/MQ0']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_ddf = dd.from_array(positions, columns=['POS'])\n",
    "is_snp_dseries = dd.from_array(is_snp)\n",
    "qual_dseries = dd.from_array(qual)\n",
    "mq0_dseries = dd.from_array(mq0)\n",
    "\n",
    "all_ddf['is_snp'] = is_snp_dseries\n",
    "all_ddf['QUAL'] = qual_dseries\n",
    "all_ddf['MQ0'] = mq0_dseries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_ddf.to_parquet('geno.parquet')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
